package com.qf.controller;/*
 *徐韬
 *2021/10/31
 *19:34
 */

import com.github.pagehelper.PageInfo;
import com.qf.dto.R;
import com.qf.pojo.TLimit;
import com.qf.service.limitService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/limit")
@Api(tags = "限制间隔时间管理，limit")
public class limitController {
    private limitService limitService;
@Autowired
    public void setLimitService(com.qf.service.limitService limitService) {
        this.limitService = limitService;
    }
    @GetMapping("/showAll")
    public R showAll(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "5") Integer pageSize){
        PageInfo<TLimit> pageInfo = limitService.showAll(pageNum, pageSize);
        return R.setOk(pageInfo);
    }
    @PostMapping("/add")
    public R add(@RequestBody TLimit tLimit){
        limitService.addlimit(tLimit);
        return R.setOk();
    }
    @PostMapping("/update")
    public R update(@RequestBody TLimit tLimit){
        System.out.println(tLimit);
        limitService.update(tLimit);
        return R.setOk();
    }
    @DeleteMapping("/delete")
    public R deleteByIds(@RequestBody Map map){
        List<Integer> ids =(List<Integer>) map.get("ids");
        limitService.deleteByids(ids);
        return R.setOk();

    }
}
